//
//  SignalAndMutipTableViewCell.m
//  Select
//
//  Created by dihuijun on 17/3/17.
//  Copyright © 2017年 Cycle. All rights reserved.
//

#import "SignalAndMutipTableViewCell.h"

@implementation SignalAndMutipTableViewCell

-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        
        ///创建子控件
        [self setupChildren];
        
//        self.backgroundColor = [UIColor orangeColor];
        
    }
    return self;
}

#pragma mark ---- 创建子控件
- (void)setupChildren
{
    //1.titleLabel
    self.titleLabel = [UILabel new];
    [self addSubview:self.titleLabel];
    //布局
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(self.contentView.mas_left).offset(10);
        make.top.mas_equalTo(self.contentView.mas_top).offset(0);
        make.height.mas_equalTo(50);
    }];
    //2.UIButton
    self.buttonSelect = [UIButton buttonWithType:UIButtonTypeCustom];
    
    [self.buttonSelect setImage:[UIImage imageNamed:@"table_UnSelect"] forState:UIControlStateNormal];
     [self.buttonSelect setImage:[UIImage imageNamed:@"table_Selected"] forState:UIControlStateSelected];
    ///不可以触摸（点击tableCell即可）
    self.buttonSelect.userInteractionEnabled = NO;
    
    [self addSubview:self.buttonSelect];
//    self.buttonSelect.backgroundColor = [UIColor redColor];
   
    //布局
    [self.buttonSelect mas_makeConstraints:^(MASConstraintMaker *make) {
//        make.right.mas_equalTo(self.contentView.mas_right).offset(300);
        make.right.mas_equalTo(self.mas_right).offset(-10);
        make.top.mas_equalTo(self.mas_top).offset(0);
        make.bottom.mas_equalTo(self.mas_bottom).offset(0);
        make.height.mas_equalTo(50);
    }];
}

/**
 *  画分割线
 */
-(void)drawRect:(CGRect)rect{
    CGContextRef context = UIGraphicsGetCurrentContext();
    //cell里面的颜色
    CGContextSetFillColorWithColor(context, [UIColor whiteColor].CGColor);
    CGContextFillRect(context, rect);
    //外边框分割线
    CGContextSetStrokeColorWithColor(context, [UIColor groupTableViewBackgroundColor].CGColor);
    CGContextStrokeRect(context, CGRectMake(0, rect.size.height-0.5, rect.size.width, 0.5));
}
/**
 *  更新按钮状态
 */
- (void)updateButtonState:(BOOL)select{
    self.buttonSelect.selected = select;
    self.isSelected = select;
}
@end
